//
//  ENMineTableHeaderView.m
//  EverydayNews
//
//  Created by 李沛池 on 2017/7/22.
//  Copyright © 2017年 Godlike. All rights reserved.
//

#import "ENMineTableHeaderView.h"
#import "ENLoginViewController.h"
#import "UserModel.h"
#import <UIButton+WebCache.h>

@interface ENMineTableHeaderView ()

@property (weak, nonatomic) IBOutlet UIButton *btnHeader;
@property (weak, nonatomic) IBOutlet UILabel *labelName;

@end

@implementation ENMineTableHeaderView

- (void)updateData:(UserModel *)user
{
    if (user) {
        _btnHeader.userInteractionEnabled = NO;
        [_btnHeader sd_setBackgroundImageWithURL:[NSURL URLWithString:user.userIcon] forState:UIControlStateNormal placeholderImage:ImageNamed(@"util_headerImage_default.png")];
        _labelName.text = user.userNickName;
    }else {
        _btnHeader.userInteractionEnabled = YES;
        [_btnHeader setBackgroundImage:ImageNamed(@"util_headerImage_default.png") forState:UIControlStateNormal];
        _labelName.text = @"登录";
    }
}

- (IBAction)loginAction:(id)sender
{
    ENLoginViewController *enlVC = StoryboardXIIBVC(@"ENLoginViewController");
    [self.viewController.navigationController pushViewController:enlVC animated:YES];
}


@end
